package mission2.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class  HibernateUtil {
	 private static SessionFactory sessionFactory;
	    private HibernateUtil(){
	    }
	    //初始化

	    static{
	  	  Configuration cfg = new Configuration();
	          cfg.configure();
	   	  sessionFactory = cfg.buildSessionFactory();
	    }    
	    
	    public static SessionFactory getSessionFactory(){
	  	return sessionFactory;
	    }
	   
	    public static Session getSession(){
	  	return sessionFactory.openSession();
	    }
}